#!/bin/sh

#  This file is part of Urd.
#
#  Urd is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.
#  Urd is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program. See the file "COPYING". If it does not
#  exist, see <http://www.gnu.org/licenses/>.
#
# $LastChangedDate: 2008-03-18 17:16:06 +0100 (Tue, 18 Mar 2008) $
# $Rev: 1030 $
# $Author: styck $
# $Id: install.sh 1030 2008-03-18 16:16:06Z styck $
#

#This file is ubuntu specific

uid=$(id -u)

echo "-= URD installer for BSD =-"
echo 
echo "This is far from complete. If you can complete it post the script at the forum: http://www.urdland.com"

if [ "$uid" != "0" ] ; then
	echo "must run as root"
	exit
fi


#TODO need to be updated
needed_packages="apache2 php5 mysql-server php5-cli php5-mysql yydecode unrar par2 smarty"
optional_packages="php5-xmlrpc php5-curl arj p7zip-full unace-nonfree trickle unzip tar cksfv "



#TODO must be set to correct files
php_apache_ini="/etc/php5/apache2/php.ini"
php_cli_ini="/etc/php5/cli/php.ini"

read -p "Install optional packages [y/n]" si

echo 
# do an upgrade first

#TODO


# install the required packages

#TODO

# if the user said yes, also install the optional packages
if [ "$si" = "y" -o "$si" = "yes" ] ; then
	echo "Installing optional packages $optional_packages"

	#TODO
fi

# run the generic installer to do its thing
echo
echo "Creating urd user and group"
./install.sh

echo 
echo "checking php memory limit:"
grep "^;*memory_limit" $php_cli_ini
echo "if the limit is below 128M run 'sudo vi $php_cli_ini' and change the setting"

echo 
echo "checking include path in php:"
grep "^;*include_path" $php_apache_ini
echo "is it a comment? Uncomment it and make sure it include '/usr/share/php'"

#TODO fill in apache
echo "you may have to restart apache: ##APACHE## restart"

echo 
echo
echo "Install phase 1 complete. Now go to the webbrowser and run phase 2"
echo "eg http://[YOUR IP-ADDRESS OR HOSTNAME]/urd/"

echo
# make sure we end
exit

